<?php
# page =  2 
$index=$_REQUEST["index"];
# 链接数据库
$db = mysqli_connect("127.0.0.1", "root", "", "mogujie");

# 查询获取数据库中的数据
# page 1 = 0,20
# page 2 = 20,20
# page 3 = 40,20
// $start = ($_REQUEST["page"] - 1) * 10;
if($index==0){
    $sql = "SELECT * FROM list13";
}elseif($index==1){
    $sql="SELECT * FROM `list13` ORDER BY`list13`.`nowPrice` DESC";
}elseif($index==2){
    $sql="SELECT * FROM `list13` ORDER BY `list13`.`nowPrice` ASC";
}elseif($index==3){
    $sql="SELECT * FROM `list13` ORDER BY `list13`.`num` DESC";
}
    

$result = mysqli_query($db,$sql);

$data = mysqli_fetch_all($result,MYSQLI_ASSOC);
// print_r($data);

# 如果1 0~19
# 如果2 20~39

# 把数据转换为JSON返回
echo json_encode($data,true);

#mysql数据库如何修改一列数据
#update list13 set nowPrice=replace(nowPrice, '¥', '');
#update list13 set delPrice=replace(delPrice, '¥', '');
?>